#ifndef HLE_H
#define HLE_H

#include "hle/__Kernel.h"
#include "cpu/mips.h"
#include "log.h"

typedef void (* HLEFunc)();

typedef struct
{
    u32 nid;
    HLEFunc func;
} HLEExport;

typedef struct
{
    char *name;
    HLEExport *funcs;
    u32 numFuncs;
} HLELibrary;

#define LIB_START(library) HLEExport library[] = {
#define LIB_ADDFUNC(nid, func) {nid, func},
#define LIB_END };

#define HLEDECL __cdecl

#define PARAM(n) cpu.r[A0 + n]
#define RETURN(n) cpu.r[V0] = n
#define RETURN1(n) cpu.r[V1] = n

#define NOTIMPL(n) _log(WRN, "HLE", "Not implemented syscall %s", n)

#define NID_THRET 0xdeadbeef
#define NID_CBRET 0xdeadbabe

char *hle_getNidName(u32 nid);
void hle_callSyscall(u32 op);
u16 hle_getNewSyscall(const char *library, u32 nid);
char *hle_getSyscallName(u16 id);
void hle_addExport(const char *library, u32 nid, u32 addr);

#endif

